import React, { useState, forwardRef, useImperativeHandle } from 'react'

function Child (props, ref) {
  const [count, setCount] = useState(100)

  // 暴露子组件中的内容
  // vue3 defineExpose
  useImperativeHandle(ref, () => {
    return {
      setCount
    }
  })

  return (
    <div>
      Child
      <p>count is {count}</p>
    </div>
  )
}

export default forwardRef(Child)
